home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / misc / wvware-mos.lha / bin / wvWml < prev   
Text File  |  2002-05-07  |  3KB  |  144 lines

  1. #!/bin/sh
  2.  
  3. wv_script_name="$0"
  4.  
  5. prefix=/gg
  6. exec_prefix=
  7. datadir=
  8. t_dir=.
  9.  
  10. wv_opts=
  11. i_file=
  12. o_file=
  13. print_help=no
  14.  
  15. while test $# -gt 0; do
  16.   case "$1" in
  17.   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  18.   *) optarg= ;;
  19.   esac
  20.  
  21.   case $1 in
  22.     --prefix=*)
  23.       prefix=$optarg
  24.       ;;
  25.     --exec-prefix=*)
  26.       exec_prefix=$optarg
  27.       ;;
  28.     --datadir=*)
  29.       datadir=$optarg
  30.       ;;
  31.     --targetdir=*)
  32.       t_dir=$optarg
  33.       ;;
  34.     --charset=* | --password=*)
  35.       wv_opts="$wv_opts $1"
  36.       ;;
  37.     -v | --version)
  38.       echo 0.7.2
  39.       exit 0
  40.       ;;
  41.     -\? | -h | --help)
  42.       cat << EOF
  43. Usage: $wv_script_name [OPTIONS] <input-file> <output-file>
  44. Options:
  45.       --prefix=<DIR>        Set prefix (default is /gg)
  46.       --exec-prefix=<DIR>   Set exec_prefix (default is ${prefix})
  47.       --datadir=<DIR>       Set datadir (default is ${prefix}/share)
  48.       --targetdir=<DIR>     Target directory (target is <DIR>/<output-file>)
  49.       --charset=<charset>   Specify an iconv charset encoding
  50.       --password=<password> Specify password for encrypted
  51.   -v, --version             Print version info and exit
  52.  
  53. Authors:
  54.   Dom Lachowicz (dominicl@seas.upenn.edu)
  55.   Caolan McNamara (original author)
  56. Visit http://www.wvware.com/
  57. EOF
  58.       exit 0
  59.       ;;
  60.     -?*)
  61.       echo "Option '$1' not recognized."
  62.       exit 1
  63.       ;;
  64.     *)
  65.       if test "x$i_file" = "x"; then
  66.         i_file=$1
  67.       elif test "x$o_file" = "x"; then
  68.         o_file=$1
  69.       else
  70.         echo "Option '$1' not recognized."
  71.         exit 1
  72.       fi
  73.       ;;
  74.   esac
  75.   shift
  76. done
  77.  
  78. if test "x$i_file" = "x-"; then
  79.   echo "error: cannot specify '-' as input"
  80.   exit 1
  81. fi
  82. if test -r "$i_file"; then
  83.   okay=yes
  84. else
  85.   echo "error: '$i_file' unreadable"
  86.   exit 1
  87. fi
  88.  
  89. if test "x$o_file" = "x"; then
  90.   echo "Usage: $1 [OPTIONS] <input-file> <output-file>"
  91.   exit 1
  92. fi
  93. name=`basename "$o_file"`
  94. if test "x$o_file" != "x$name"; then
  95.   echo "* * * Better to use '--targetdir' for writing in another directory * * *"
  96.   exit 1
  97. fi
  98. name=`echo $name | sed 's/\.[^\.]*$//'`
  99.  
  100. if test "x$exec_prefix" = "x"; then
  101.   exec_prefix=${prefix}
  102. fi
  103. wv_exec="$exec_prefix/bin/wvWare"
  104. if test -x "$wv_exec"; then
  105.   okay=yes
  106. else
  107.   wv_version=`wvWare -v 2>&1 | cut -f 2 -d " "`
  108.   if test "x$wv_version" = "x0.7.2"; then
  109.     wv_exec="wvWare"
  110.   else
  111.     echo "error: no executable at '$wv_exec' or in path"
  112.     exit 1
  113.   fi
  114. fi
  115.  
  116. if test "x$datadir" = "x"; then
  117.   datadir=${prefix}/share
  118. fi
  119. xmlcfg="$datadir/wv/wvWml.xml"
  120. if test -r "$xmlcfg"; then
  121.   okay=yes
  122. else
  123.   echo "error: '$xmlcfg' unreadable"
  124.   exit 1
  125. fi
  126.  
  127. if test -d "$t_dir"; then
  128.   if test -w "$t_dir"; then
  129.     okay=yes
  130.   else
  131.     echo "error: '$t_dir' is not writable"
  132.     exit 1
  133.   fi
  134. else
  135.   echo "error: '$t_dir' is not a directory"
  136.   exit 1
  137. fi
  138.  
  139. if test "x$o_file" = "x-"; then
  140.   "$wv_exec" $wv_opts -x "$xmlcfg" -d "$t_dir" -b "$name" "$i_file"
  141. else
  142.   "$wv_exec" $wv_opts -x "$xmlcfg" -d "$t_dir" -b "$name" "$i_file" > "$t_dir"/"$o_file"
  143. fi
  144.